# -*- coding: utf-8 -*-
# 如果你的程序（包括注释）中包含中文，请加上上面这一行，用于指明编码（utf-8）。
# #号开头的行都是注释。

# 如何编辑本程序：
#     用任何文本编辑器均可编辑。

# 如何运行本程序：
#     在终端中，运行：python p302_return.py

# 返回一个数值的函数：
def fibonacci(n):
    '''Given a number n, return F(n).
    Param: n must be a positive integer.
    '''
    f_series = [1, 1]
    i = 2
    while i <= n:
        f_series.append(f_series[i-2] + f_series[i-1])
        i += 1   
    return f_series[n]

print(fibonacci(10))


# 返回一个列表的函数：
def fibonacci_series(n):
    '''Given a number n, return F(0), ..., F(n)
    Param: n must be a positive integer.
    '''
    f_series = [1, 1]
    i = 2
    while i <= n:
        f_series.append(f_series[i-2] + f_series[i-1])
        i += 1   
    return f_series
    
print(fibonacci_series(10))


# 返回字典的函数：
def build_person(name, nation, age):
    person = { 'name': name, 'nation': nation, 'age': age }
    return person
    
p1 = build_person('Zhang Lao San', 'China', 25)
print(p1)


# 返回元组的参数：
def calc_stats(numbers):
    '''Given a list of numbers, count the number and find
    the maximum and the minimum.
    '''
    num_numbers = len(numbers)
    max_number = max(numbers)
    min_number = min(numbers)
    return (num_numbers, max_number, min_number)
    
print(calc_stats([3, 5, 8, 10, -3, 9]))



    
    










